package com.imm.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.imm.common.Result;
import com.imm.dto.DishDTO;
import com.imm.dto.SetmealDTO;
import com.imm.pojo.Setmeal;
import com.imm.service.ISetmealService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Resource
    private ISetmealService setmealService;




    @GetMapping("/page")
    public Result<Page> page(int page, int pageSize, String name) {
        return setmealService.pageSetmeal(page, pageSize, name);
    }

    @PostMapping
    public Result<String> insert(@RequestBody SetmealDTO setmealDTO) {
        return setmealService.insert(setmealDTO);
    }


    @PostMapping("/status/{status}")
    public Result<String> changeStatus(@PathVariable("status") Integer status, Long ...ids) {
        return setmealService.changeStatus(status, ids);
    }

    @GetMapping("/list")
    public Result<List<Setmeal>> list(Setmeal setmeal) {
        return setmealService.listSetmeal(setmeal);
    }

    @DeleteMapping
    public Result<String> delete(Long ...ids) {
        return setmealService.delete(ids);
    }

    @GetMapping("/dish/{id}")
    public Result<List<DishDTO>> dishList(@PathVariable("id") Long id) {
        return setmealService.dishList(id);
    }

}
